package collect.taobao.action;

import javax.servlet.ServletContext;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import collect.taobao.bean.UserBean;
import collect.taobao.service.UserService;
import collect.taobao.util.Md5;
import collect.taobao.util.SuperAction;

public class UserAction extends SuperAction {
	private String userName;
	private String passWord;

	public UserAction() {
		super();
	}

	public String userLogin() {
		ServletContext servletContext = this.getReq().getSession().getServletContext();
		ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
		UserService userLogin = (UserService) ctx.getBean("userServerInterface");
		UserBean userBean = new UserBean();
		String md5PassWord = Md5.encryption(passWord);
		userBean.setUserName(userName);
		userBean.setPassWord(md5PassWord);
		userLogin.save(userBean);
		return "success";
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassWord() {
		return passWord;
	}

	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}

}
